package com.vancouver.knows.ui.activity.my;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Message;
import android.widget.LinearLayout;
import android.widget.TextView;
import butterknife.Bind;
import butterknife.OnClick;

import com.vancouver.knows.R;
import com.vancouver.knows.ui.base.BaseActivity;
import com.vancouver.knows.business.Constants;

public class MyArticleActivity extends BaseActivity {

	private Context mContext;
	@Bind(R.id.text_tips)
	TextView mTextTips;
	@Bind(R.id.my_article_layout)
	LinearLayout myArticleLayout;
	private MyArticlePullRefreshView mController;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.my_article_activity);
		mContext = MyArticleActivity.this;
		setViews();
	}

	private void setViews() {
		Intent intent = getIntent();
		mTextTips.setText(intent.getStringExtra("MY_TITLE"));
		loadView();
	}

	private void loadView() {
		mController = new MyArticlePullRefreshView(mContext);
		mController.loadData();
		myArticleLayout.addView(mController);
	}

	@OnClick(R.id.cancel)
	public void onCancelClick() {
		finish();
	}

	@Override
	public void subHandleMessage(Message msg) {
		super.subHandleMessage(msg);

		switch (msg.what) {
		case Constants.BUSINESS_STATUS_USER_DEL_ARTICLE:
			mController.flush();
			break;
		}
	}

}